import {observable,action} from 'mobx';
import { WeaTableNew } from 'comsMobx';
import { message } from 'antd'
import * as goalOrgShare from '../../apis/goal/goalOrgShare'
import {WeaLocaleProvider} from 'ecCom';
const toJS = mobx.toJS;
const getLabel = WeaLocaleProvider.getLabel;
const { TableStore } = WeaTableNew;
export default class GoalOrgShareStore {

    @observable loading = false;
    @observable shareTable =  new TableStore();

     //任务共享展示
     @action
     goalOrgShareList = (params) => {
         this.loading = true;
         goalOrgShare.goalOrgShareList(params).then(action(res=>{
             if(res.status){
                 this.shareTable.getDatas(res.datas)
                 this.loading = false;
             }  
         }));
     }
 
     //组织目标共享设置
     goalOrgShareSetting = (params) => {
         this.loading = true;
         goalOrgShare.goalOrgShareSetting(params).then(action(res=>{
             if(res.status){
                 if(params.operate == 'add'){
                      message.success(getLabel(22619,'保存成功'));
                 }else if(params.operate == 'query'){
                      this.cateData = res.data;
                 }else if(params.operate == 'del' || params.operate == "batch"){
                     if(res.result){
                        message.success(getLabel(20461,'删除成功'));
                     }else{
                        message.error(getLabel('25009','失败'))
                     }
                    
                 }else if(params.operate == 'update'){
                      message.success(getLabel(31439,'更新成功'));
                 }
                 if (typeof params.doback === "function") {
                      params.doback();
                  }
                 this.loading = false;
              }  
         }));
     }

}